<?php
session_start();
if (!$_SESSION["status"]) {
    header("location:../managerlogin.php");
}
include_once "../model/model.php";
include_once "../model/pile.php";

define("BUSY", "会议室已被占用！");
define("ERROR", "系统错误");

if (isset($_POST["index"]) && $_POST["index"] != null) {
	$distribute_room = new MEETING();
	$result = $distribute_room->review_meeting_room($_POST["index"], $_POST["check"]);
	switch ($result) {
		case MEETING::full: {
				/* echo "会议室已被占用！"; */
			$status = -1;
			}
			break;

		case MEETING::ok:
			//echo "操作成功";
			header("location:../admin/check.php");
			/* echo "<script>window.location.assign('../admin/check.php')</script>"; */
			break;
		case MEETING::error:
			/* echo "system error!"; */
			$status = -2;
			break;
		default:
			/* echo "系统错误"; */
			$status = -2;
	}
?>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf8">
        <title>管理员审核表</title>
        <link rel="stylesheet" href="../public/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="../css/check.css">

    </head>
    <body>
        <div id = "main">
            <br>
            <br><br><br><br><br><br>
            <h1 align="center"><strong>处理结果</strong></h1>

            <h2 align="center">
                <?php
                /* include_once "../model/model.php"; */
                /* include_once "../model/pile.php"; */
                /* if (isset($_POST["index"]) && $_POST["index"] != null) { */
                /*     $distribute_room = new MEETING(); */
                /*     $result = $distribute_room->review_meeting_room($_POST["index"], $_POST["check"]); */
                /*     switch ($result) { */
                /*         case MEETING::full: { */
                /*                 echo "会议室已被占用！"; */
                /*             } */
                /*             break; */

                /*         case MEETING::ok: */
                /*             //echo "操作成功"; */
                /*             /1* header("location:../admin/check.php"); *1/ */
							/* echo "<script>window.location.assign('../admin/check.php')</script>"; */
                /*             break; */
                /*         case MEETING::error: */
                /*             echo "system error!"; */
                /*             break; */
                /*         default: */
                /*             echo "系统错误"; */
                /*     } */
				if($status === -1)
				{
					echo BUSY;
				}
				elseif($status === -2)
				{
					echo ERROR;
				}
				echo "<a href = '../admin/check.php'>返回</a>";
                    //echo $distribute_room->review_meeting_room($_POST["index"], $_POST["check"]);
                }
                ?>
            </h2>
        </div>
    </body>
</html>
